package com.example.klinemqflink.service;

import com.example.klinemqflink.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RabbitMQProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    // 发送消息到第一个交换机
    public void sendMessageToExchange1(String routingKey, byte[] message) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.TOPIC_EXCHANGE_1, routingKey, message);
    }

    // 发送消息到第二个交换机
    public void sendMessageToExchange2(String routingKey, byte[] message) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.TOPIC_EXCHANGE_2, routingKey, message);
    }
}
